from langchain.prompts import PromptTemplate
from langchain_openai import ChatOpenAI
from langchain.prompts.chat import (
    ChatPromptTemplate,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)
from langchain.chains import LLMChain

prompt = PromptTemplate(
    input_variables=["product"],
    template="What is a good name for a company that makes {product}?",
)
print(prompt.format(product="colorful socks"))

print("-----------------------------")

chat = ChatOpenAI(temperature=0,
                  base_url="https://api.gpts.vin/v1",
                  api_key="sk-ELq6vE96xLlCHWjR21D8D93168604d2f975dF2572683464f")
template = "You are a helpful assistant that translates {input_language} to {output_language}."
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])

result = chat.invoke(chat_prompt.format_prompt(input_language="English", output_language="French", text="I love programming.").to_messages())
print(result)

print("-----------------------------")

chain = LLMChain(llm = chat, prompt = chat_prompt)
result = chain.run(input_language="English", output_language="French", text="I love programming.")
print(result)